class FuliView extends zysx.BaseView {


	private getGift:eui.Image;

	private giveUpFuli:eui.Label;

	private image1:eui.Image;

	private image2:eui.Image;

	private time_gift:eui.Group;

	private time_text:eui.Label;

	private timerSec = 10;
	public constructor(data?) {
		super(data);
		this.skinName = "FuliSkin";
	}

	public initComponent(): void {
			super.initComponent();
	}

	public initListener(): void {
		super.initListener();
		this.addEvent(this.giveUpFuli, egret.TouchEvent.TOUCH_TAP, this.closeSelf, this);	
		this.addEvent(this.getGift, egret.TouchEvent.TOUCH_TAP, this.gift, this);
	}

	//领取礼包
	private gift():void{
		var that = this;
		ShareMgr.share({shareBack(){
			UserMgr.ins.addGold(200);
			if(that.data == 1){
				UserMgr.ins.getDayGift();
			}else{
				UserMgr.ins.getNewGift();
			}
			that.closeSelf()
		}});
		;
	}


	public onOpen(data?): void {
		super.onOpen(data);
		this.initView();
		
	}
	private initView(): void{	

		if(this.data == 1){
			this.image1.texture = RES.getRes("jbdlb_png"); 
			this.image2.texture = RES.getRes("gold2_png"); 
			this.getGift.texture = RES.getRes("ljlq_png");
		}else{
			this.image1.texture = RES.getRes("xsdlb_png"); 
			this.image2.texture = RES.getRes("gold2_png"); 
			this.getGift.texture = RES.getRes("ljlq_png");
		}

		if(this.data == 3){
			this.time_gift.visible = true;
			var timer:egret.Timer = new egret.Timer(1000,10);
			timer.addEventListener(egret.TimerEvent.TIMER,this.timerTick,this);
			timer.start();
		}

		this.giveUpFuli.textFlow = new Array<egret.ITextElement>(
            { text:" 放弃福利", style: { underline:true } } 
        );
		
		var tw = egret.Tween.get( this.getGift, { loop:true} );

		tw.to({scaleX:1.1,scaleY:1.1},250)
		.to({scaleX:1,scaleY:1},250)
		.to({scaleX:0.9,scaleY:0.9},250)
		.to({scaleX:1,scaleY:1},250).wait(1000);

	}

	private timerTick():void{
		this.timerSec--;
		this.time_text.text = this.timerSec+"秒"
		if(this.timerSec == 0){
			this.closeSelf();
		}
	}

}
window["FuliView"] = FuliView;